<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Matrix207&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Matrix207's Blog">
<meta property="og:url" content="http://yoursite.com/page/2/index.html">
<meta property="og:site_name" content="Matrix207's Blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Matrix207's Blog">
  
    <link rel="alternate" href="/atom.xml" title="Matrix207&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Matrix207&#39;s Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-c" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/05/c/" class="article-date">
  <time datetime="2016-03-04T16:00:00.000Z" itemprop="datePublished">2016-03-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/05/c/">c</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Books"><a href="#Books" class="headerlink" title="Books"></a>Books</h3><h3 id="Projects"><a href="#Projects" class="headerlink" title="Projects"></a>Projects</h3><ul>
<li>1.<a href="http://home.tiscali.cz/~cz210552/webbench.html" target="_blank" rel="external">Webbench</a></li>
<li>2.<a href="http://sourceforge.net/projects/tinyhttpd/" target="_blank" rel="external">Tinyhttpd</a></li>
<li>3.<a href="http://sourceforge.net/projects/cjson/" target="_blank" rel="external">cJSON</a></li>
<li>4.<a href="http://code.google.com/p/cmockery/downloads/list" target="_blank" rel="external">CMokery</a></li>
<li>5.<a href="http://software.schmorp.de/pkg/libev.html" target="_blank" rel="external">Libev</a></li>
<li>6.<a href="http://memcached.org/" target="_blank" rel="external">Memcached</a></li>
<li>7.<a href="http://www.lua.org/" target="_blank" rel="external">Lua</a></li>
<li>8.<a href="http://www.sqlite.org/" target="_blank" rel="external">SQLite</a></li>
<li>9.<a href="http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6" target="_blank" rel="external">UNIX v6</a></li>
<li>10.<a href="http://www.netbsd.org/" target="_blank" rel="external">NETBSD</a></li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="http://blog.jobbole.com/79023/" target="_blank" rel="external">最值得阅读学习的 10 个 C 语言开源项目代码</a></li>
<li><a href="https://notabug.org/koz.ross/awesome-c" target="_blank" rel="external">https://notabug.org/koz.ross/awesome-c</a></li>
<li><a href="https://github.com/jobbole/awesome-c-cn" target="_blank" rel="external">https://github.com/jobbole/awesome-c-cn</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/05/c/" data-id="ciqqpe1v300elnmpv1s8nx6nc" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-wrong-coding-in-cplusplus" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/05/wrong-coding-in-cplusplus/" class="article-date">
  <time datetime="2016-03-04T16:00:00.000Z" itemprop="datePublished">2016-03-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/05/wrong-coding-in-cplusplus/">Wrong coding in c++</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Use-exception-instead-return-boolean"><a href="#Use-exception-instead-return-boolean" class="headerlink" title="Use exception instead return boolean"></a>Use exception instead return boolean</h3><p>Sample code as below:</p>
<pre><code>try {
    // Do something here, which may throw exception
} catch (MyException&amp; e) {
    if (e.getError() == MyExceptionA) {
        // Do another normal operation
    }
}
</code></pre><h3 id="Throw-exception-in-loop"><a href="#Throw-exception-in-loop" class="headerlink" title="Throw exception in loop"></a>Throw exception in loop</h3><h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/05/wrong-coding-in-cplusplus/" data-id="ciqqpe1v800ernmpvzulttm2j" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-cplusplus" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/03/05/cplusplus/" class="article-date">
  <time datetime="2016-03-04T16:00:00.000Z" itemprop="datePublished">2016-03-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/03/05/cplusplus/">c++</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Books"><a href="#Books" class="headerlink" title="Books"></a>Books</h3><ul>
<li><a href="http://www.parashift.com/c++-faq-lite/" target="_blank" rel="external">C++FAQS</a></li>
<li>Junior<ul>
<li><a href="">(C++11)C++11 - 维基百科，自由的百科全书</a></li>
<li><a href="">(C++11)深入理解C++11：C++ 11新特性解析与应用 迷你</a></li>
<li>[C++标准程序库–自修教程与参考手册]</li>
<li>[C++程序设计原理与实践]</li>
<li>[C++程序设计语言 特别版]</li>
<li>[C++编程惯用法——高级程序员常用方法和技巧]</li>
<li>[C++编程规范-101条规则准则与最佳实践]</li>
<li>[C++语言的设计和演化]</li>
<li>[C++释难解惑]</li>
<li>[C和C++安全编码（中文版）]</li>
<li>[Effective C++中文版（第三版）]</li>
<li>[More Effective C++ 中文版]</li>
<li>[[Effective STL中文版：50条有效使用STL的经验]]</li>
<li>[Exceptional C++ Style(Herb Sutter).中文版]</li>
<li>[Exceptional C++ 中文版]</li>
<li>[More Exceptional C++(中文版)]</li>
<li>[From C++ to Objective-C-english]</li>
<li>[From C++ to Objective-C-中文版]</li>
<li>[Linux C编程一站式学习6.14–宋劲衫]</li>
<li>[从缺陷中学习C、C++]</li>
<li>[你必须知道的222个C++语言问题.范立锋.扫描版]</li>
<li>[标准C++库函数参考]</li>
<li>[深入学习：GNU C++ for Linux 编程技术]</li>
<li>[编写高质量代码 改善C++程序的150个建 议.李健.扫描版]</li>
</ul>
</li>
<li>C/C++进阶<ul>
<li>[Accelerated C++中文版 ]</li>
<li>[Advanced c++ Programming Styles and Idioms中文版]</li>
<li>[C++ API设计–英文版]</li>
<li>[C++ Templates中文版]</li>
<li><a href="http://www.cnblogs.com/Solstice/category/287661.html" target="_blank" rel="external">C++ 工程实践经验谈–陈硕</a></li>
<li>[C++ API设计]</li>
<li>[C++代码设计与重用]</li>
<li>[C++标准库——自学教程与参考手册(第2版)英文版]</li>
<li>[C++沉思录(Ruminations on C++)中文第2版]</li>
<li>[C++程序设计]</li>
<li>[C++设计新思维(Modern_C++_Design)]</li>
<li>[大规模C++程序设计]</li>
<li>[模板编程与OO编程范型–混搭]</li>
<li>[深度探索C++对象模型]</li>
<li>[高质量C++／C编程指南]</li>
<li>[Imperfect C++]</li>
<li>[C++ 并发编程指南]</li>
</ul>
</li>
</ul>
<h3 id="Projects"><a href="#Projects" class="headerlink" title="Projects"></a>Projects</h3><ul>
<li>1.<a href="https://github.com/google/leveldb" target="_blank" rel="external">leveldb</a><ul>
<li>Google出品，遵循Google C++编码规范</li>
<li>作者是Jeff Dean大神</li>
<li>涉及查找、缓存、文件读写、多线程、跨平台等诸多常见问题</li>
<li>最新版本1.15.0代码量也不到2万行</li>
<li>基础的key-value数据库，广泛用于Google内部和许多开源项目</li>
</ul>
</li>
<li><a href="http://code.google.com/p/googletest/" target="_blank" rel="external">Google Test</a></li>
<li><a href="https://developers.google.com/protocol-buffers/" target="_blank" rel="external">Protocol Buffers</a></li>
<li>2.<a href="http://www.llvm.org/" target="_blank" rel="external">llvm</a></li>
<li>2.<a href="https://github.com/google/leveldb" target="_blank" rel="external">muduo</a></li>
</ul>
<h3 id="Lambda"><a href="#Lambda" class="headerlink" title="Lambda"></a>Lambda</h3><ul>
<li><a href="http://zh.cppreference.com/w/cpp/language/lambda" target="_blank" rel="external">http://zh.cppreference.com/w/cpp/language/lambda</a></li>
</ul>
<h3 id="resource-manager"><a href="#resource-manager" class="headerlink" title="resource manager"></a>resource manager</h3><ul>
<li><p>Implement ScopeGuard</p>
<ul>
<li><a href="https://en.wikibooks.org/wiki/More_C++_Idioms/Scope_Guard" target="_blank" rel="external">https://en.wikibooks.org/wiki/More_C++_Idioms/Scope_Guard</a></li>
<li><a href="http://mindhacks.cn/2012/08/27/modern-cpp-practices/" target="_blank" rel="external">http://mindhacks.cn/2012/08/27/modern-cpp-practices/</a></li>
</ul>
</li>
<li><p>Sample code:</p>
<pre><code>// TODO: not work
// g++ -o t -std=c++11 c++11.cc
#include &lt;stdio.h&gt;
#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;functional&gt;

#define TT_HERE() {std::cout &lt;&lt; __FUNCTION__ &lt;&lt; &quot;:&quot; &lt;&lt; __LINE__ &lt;&lt; std::endl;}
#define TT_PRINT_MSG(x) {std::cout &lt;&lt; __LINE__ &lt;&lt; &quot;:&quot; &lt;&lt; x &lt;&lt; std::endl;}

class ScopeGuard
{
public:
    explicit ScopeGuard(std::function&lt;void()&gt; onExitScope)
        : onExitScope_(onExitScope), dismissed_(false)
    { }

    ~ScopeGuard()
    {
        TT_HERE();
        if(!dismissed_)
        {
            onExitScope_();
        }
    }

    void Dismiss()
    {
        dismissed_ = true;
    }

private:
    std::function&lt;void()&gt; onExitScope_;
    bool dismissed_;

private: // noncopyable
    ScopeGuard(ScopeGuard const&amp;);
    ScopeGuard&amp; operator=(ScopeGuard const&amp;);
};

#define SCOPEGUARD_LINENAME_CAT(name, line) name##line
#define SCOPEGUARD_LINENAME(name, line) SCOPEGUARD_LINENAME_CAT(name, line)

#define ON_SCOPE_EXIT(callback) ScopeGuard SCOPEGUARD_LINENAME(EXIT, __LINE__)(callback)

class A
{
public:
    A () { TT_HERE(); }
    ~A () { TT_HERE(); }
};

void release()
{
    std::cout &lt;&lt; &quot;do release&quot; &lt;&lt; std::endl;
}

class B
{
public:
    B () {
        TT_HERE();
    }
    ~B () { TT_HERE(); }
    void Fun1() {
        A a;
        std::cout &lt;&lt; &quot;do something in Fun1&quot; &lt;&lt; std::endl;
        std::cout &lt;&lt; &quot;throw exception&quot; &lt;&lt; std::endl;
        throw;
        release;
    }
};

class C
{
public:
    C () {
        TT_HERE();
    }
    ~C () { TT_HERE(); }
    void Fun1() {
        A a;
        ON_SCOPE_EXIT( [&amp;] { release();} );
        std::cout &lt;&lt; &quot;do something in Fun1&quot; &lt;&lt; std::endl;
        std::cout &lt;&lt; &quot;throw exception&quot; &lt;&lt; std::endl;
        throw;
    }
};

void Test1()
{
    std::vector&lt;int&gt; v;
    v.push_back(1);
    v.push_back(2);
    v.push_back(3);

    std::for_each(std::begin(v), std::end(v), [](int n) {std::cout &lt;&lt; n &lt;&lt; std::endl;});

    auto is_odd = [](int n) {return n%2==1;};
    auto pos = std::find_if(std::begin(v), std::end(v), is_odd);
    if(pos != std::end(v))
        std::cout &lt;&lt; *pos &lt;&lt; std::endl;
}

int main()
{
    std::cout &lt;&lt; &quot;------------------------&quot; &lt;&lt; std::endl;
    B b;
    //b.Fun1();
    std::cout &lt;&lt; &quot;------------------------&quot; &lt;&lt; std::endl;
    C c;
    c.Fun1();
    std::cout &lt;&lt; &quot;------------------------&quot; &lt;&lt; std::endl;

    return 0;
}
</code></pre></li>
</ul>
<h3 id="Error-handle"><a href="#Error-handle" class="headerlink" title="Error handle"></a>Error handle</h3><ul>
<li>Target:<ul>
<li>easy to use</li>
<li>more error message</li>
<li>be strong</li>
</ul>
</li>
<li><p>Error information collection</p>
<ul>
<li>information include: error, location and context</li>
<li><p><code>ENSURE(0 &lt;= index &amp;&amp; index &lt; v.size())(index)(v.size());</code></p>
<pre><code>Failed: 0 &lt;= index &amp;&amp; index &lt; v.size()  (error)
File: xxx.cpp Line: 123                 (location)
Context Variables:                      (context)
    index = 12345
    v.size() = 100
</code></pre></li>
<li><p>support multiple express <code>(ENSURE(expr)(var1)(var2)(var3))</code></p>
</li>
<li><code>static_assert(std::is_same&lt;decltype(expr), bool&gt;::value, &quot;ENSURE(expr) can only be used on bool expression&quot;);</code></li>
</ul>
</li>
<li><p>Implementation sample</p>
<pre><code>// Create by matrix207 2016-03-08
// compile: g++ -o t -std=c++0x ensure.cc
// expand macro with : g++ -E -P -std=c++0x ensure.cc
#include &lt;exception&gt;
#include &lt;iostream&gt;
#include &lt;sstream&gt;

class MyException
{
public:
    MyException(const char *exp, const char *file, int line)
        : SMART_ASSERT_A (*this),
          SMART_ASSERT_B (*this)
    {
        std::ostringstream so;
        so &lt;&lt; &quot;Ensure failed : &quot; &lt;&lt; &apos;\n&apos;
           &lt;&lt; &apos;\t&apos; &lt;&lt; &quot;Expression : &quot; &lt;&lt; exp &lt;&lt; &apos;\n&apos;
           &lt;&lt; &apos;\t&apos; &lt;&lt; &quot;Location : &quot; &lt;&lt; file &lt;&lt; &apos;:&apos; &lt;&lt; line &lt;&lt; &apos;\n&apos;;
        m_what += so.str();
    }
    template&lt;typename T&gt;
    MyException&amp; printVariable(const char* name, T v)
    {
        std::ostringstream so;
        so &lt;&lt; &apos;\t&apos; &lt;&lt; name &lt;&lt; &quot; : &quot; &lt;&lt; v &lt;&lt; &apos;\n&apos;;
        m_what += so.str();
        return *this;
    }
    MyException&amp; err(int error)
    {
        std::ostringstream so;
        so &lt;&lt; &apos;\t&apos; &lt;&lt; &quot;Error : &quot; &lt;&lt; error &lt;&lt; &apos;\n&apos;;
        m_what += so.str();
        return *this;
    }
    MyException&amp; msg(const char* msg)
    {
        std::ostringstream so;
        so &lt;&lt; &apos;\t&apos; &lt;&lt; &quot;Message : &quot; &lt;&lt; msg &lt;&lt; &apos;\n&apos;;
        m_what += so.str();
        return *this;
    }
    const char *what() const throw ()
    {
        return m_what.c_str();
    }
    MyException&amp; SMART_ASSERT_A;
    MyException&amp; SMART_ASSERT_B;
private:
    mutable std::string m_what;
};

#define SMART_ASSERT_A(x) SMART_ASSERT_AB(x, B)
#define SMART_ASSERT_B(x) SMART_ASSERT_AB(x, A)
#define SMART_ASSERT_AB(x,next) \
    SMART_ASSERT_A.printVariable(#x,(x)).SMART_ASSERT_ ## next

#define MY_ENSURE(expr) \
    if (expr); else throw MyException(#expr,__FILE__,__LINE__).SMART_ASSERT_A

int main()
{
    try
    {
        int a = 2;
        MY_ENSURE(a &gt; 3)(a).err(10001).msg(&quot;error occur!&quot;);
    }
    catch (const MyException&amp; e)
    {
        std::cout &lt;&lt; &quot;catch exception:\n&quot; &lt;&lt; e.what() &lt;&lt; std::endl;
    }
    return 0;
}
</code></pre></li>
<li><p>test</p>
<pre><code>[dennis@localhost code]$ g++ -g -o t -std=c++0x ensure.cc
[dennis@localhost code]$ ./t
catch exception:
Ensure failed : 
    Expression : a &gt; 3
    Location : ensure.cc:67
    a : 2
    Error : 10001
    Message : error occur!
</code></pre></li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="http://zh.cppreference.com/w/" target="_blank" rel="external">http://zh.cppreference.com/w/</a></li>
<li><a href="https://en.wikibooks.org/wiki/More_C++_Idioms" target="_blank" rel="external">https://en.wikibooks.org/wiki/More_C++_Idioms</a></li>
<li><a href="http://www.drdobbs.com/cpp/enhancing-assertions/184403745" target="_blank" rel="external">Enhancing Assertions</a></li>
<li><a href="http://www.cnblogs.com/cbscan/archive/2012/10/26/2740838.html" target="_blank" rel="external">http://www.cnblogs.com/cbscan/archive/2012/10/26/2740838.html</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/03/05/cplusplus/" data-id="ciqqpe1v500eonmpv9fidl67e" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-why-use-json" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/02/21/why-use-json/" class="article-date">
  <time datetime="2016-02-20T16:00:00.000Z" itemprop="datePublished">2016-02-21</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/02/21/why-use-json/">why use json</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Introduce"><a href="#Introduce" class="headerlink" title="Introduce"></a>Introduce</h3><p>JSON（Javascript Object Notation）</p>
<ul>
<li>JSON的如下优点，使得它快速成为最广泛使用的序列化协议之一。<ul>
<li>这种Associative array格式非常符合工程师对对象的理解。</li>
<li>它保持了XML的人眼可读（Human-readable）的优点。</li>
<li>相对于XML而言，序列化后的数据更加简洁。 来自于的以下链接的研究表明：XML所产<br>生序列化之后文件的大小接近JSON的两倍。<br><a href="http://www.codeproject.com/Articles/604720/JSON-vs-XML-Some-hard-numbers-about-verbosity" target="_blank" rel="external">http://www.codeproject.com/Articles/604720/JSON-vs-XML-Some-hard-numbers-about-verbosity</a></li>
<li>它具备Javascript的先天性支持，所以被广泛应用于Web browser的应用常景中，是Ajax的事实标准协议。</li>
<li>与XML相比，其协议比较简单，解析速度比较快。</li>
<li>松散的Associative array使得其具有良好的可扩展性和兼容性</li>
</ul>
</li>
</ul>
<h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="http://www.infoq.com/cn/articles/serialization-and-deserialization" target="_blank" rel="external">http://www.infoq.com/cn/articles/serialization-and-deserialization</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/02/21/why-use-json/" data-id="ciqqpe1v000einmpveuidnawl" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/json/">json</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-exception-vs-error-code" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/17/exception-vs-error-code/" class="article-date">
  <time datetime="2016-01-16T16:00:00.000Z" itemprop="datePublished">2016-01-17</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/17/exception-vs-error-code/">exception vs error code</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="TODO-To-be-continue"><a href="#TODO-To-be-continue" class="headerlink" title="TODO: To be continue"></a>TODO: To be continue</h3><h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h3><ul>
<li><a href="http://blog.csdn.net/pongba/article/details/1815742" target="_blank" rel="external">错误处理(Error-Handling)：为何、何时、如何(rev#2)</a></li>
<li>[1] B. Stroustrup: <a href="http://www.research.att.com/~bs/eh_brief.pdf" target="_blank" rel="external">Programming with Exceptions</a>(pdf)</li>
<li>[2] B. Stroustrup: [Exception Safety: Concepts and Techniques]<a href="http://www.research.att.com/~bs/except.pdf" target="_blank" rel="external">http://www.research.att.com/~bs/except.pdf</a></li>
<li>[3] D. Abrahams: [Error and Exception Handling]<a href="http://www.boost.org/more/error_handling.html" target="_blank" rel="external">http://www.boost.org/more/error_handling.html</a></li>
<li>[4] D. Abrahams: [Exception-Safety in Generic Components]<a href="http://www.boost.org/more/generic_exception_safety.html" target="_blank" rel="external">http://www.boost.org/more/generic_exception_safety.html</a></li>
<li>[5] Tom Cargill: [Exception Handling, A False Sense of Security]<a href="http://www.informit.com/content/images/020163371x/supplements/Exception_Handling_Article.html" target="_blank" rel="external">http://www.informit.com/content/images/020163371x/supplements/Exception_Handling_Article.html</a></li>
<li>[6] Damien Katz: [Error codes or Exceptions? Why is Reliable Software so Hard?]<a href="http://damienkatz.net/2006/04/error_code_vs_e.html" target="_blank" rel="external">http://damienkatz.net/2006/04/error_code_vs_e.html</a></li>
<li>[7] Alan Griffiths: [Here be Dragons]<a href="http://www.octopull.demon.co.uk/c++/dragons/" target="_blank" rel="external">http://www.octopull.demon.co.uk/c++/dragons/</a></li>
<li>[8] Ned Batchelder: [Exceptions vs. status returns]<a href="http://www.nedbatchelder.com/text/exceptions-vs-status.html" target="_blank" rel="external">http://www.nedbatchelder.com/text/exceptions-vs-status.html</a></li>
<li>[9] Ned Batchelder: [Exceptions in the rainforest]<a href="http://www.nedbatchelder.com/text/exceptions-in-the-rainforest.html" target="_blank" rel="external">http://www.nedbatchelder.com/text/exceptions-in-the-rainforest.html</a></li>
<li>[10] Ned Batchelder: [Fix error handling first]<a href="http://www.nedbatchelder.com/text/fix-err-hand.html" target="_blank" rel="external">http://www.nedbatchelder.com/text/fix-err-hand.html</a></li>
<li>[11] A. Alexandrescu, P. Marginean: [Change the Way You Write Exception-Safe Code — Forever]<a href="http://www.ddj.com/cpp/184403758" target="_blank" rel="external">http://www.ddj.com/cpp/184403758</a></li>
<li>[12] Brad Abrams: [Exceptions and Error Codes]<a href="http://blogs.msdn.com/brada/archive/2003/09/30/50403.aspx" target="_blank" rel="external">http://blogs.msdn.com/brada/archive/2003/09/30/50403.aspx</a></li>
<li>[13] A. Alexandrescu: [Exception Safety Analysis]<a href="http://erdani.org/publications/cuj-2003-12.pdf" target="_blank" rel="external">http://erdani.org/publications/cuj-2003-12.pdf</a>(pdf)</li>
<li>[14] Brian Goetz: [Exceptional practices]<a href="http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html?" target="_blank" rel="external">http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html?</a></li>
<li>[15] James Gosling: [Failure and Exceptions]<a href="http://www.artima.com/intv/solid.html" target="_blank" rel="external">http://www.artima.com/intv/solid.html</a></li>
<li>[16] Sun: [Advantages of Exceptions]<a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/advantages.html" target="_blank" rel="external">http://java.sun.com/docs/books/tutorial/essential/exceptions/advantages.html</a></li>
<li>[17] Vishal Kochhar: [How a C++ compiler implements exception handlin]<a href="http://www.codeproject.com/cpp/exceptionhandler.asp" target="_blank" rel="external">http://www.codeproject.com/cpp/exceptionhandler.asp</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/17/exception-vs-error-code/" data-id="ciqqpe1ux00efnmpv1k5zxs2p" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-cplusplus-11" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/17/cplusplus-11/" class="article-date">
  <time datetime="2016-01-16T16:00:00.000Z" itemprop="datePublished">2016-01-17</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/language/">language</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/17/cplusplus-11/">c++11</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="0x01-介绍"><a href="#0x01-介绍" class="headerlink" title="0x01 介绍"></a>0x01 介绍</h3><p>C++0x是C++最新标准标准化过程中的曾用名<br>在2011年9月份，C++0x正式由官方发布并命名C++11<br>C++11包括大量的新特性：主要特征像lambda表达式和移动语义，实用的类型推导关键字auto，<br>更简单的容器遍历方法，和大量使模板更容易使用的改进</p>
<h3 id="0x02-优势"><a href="#0x02-优势" class="headerlink" title="0x02 优势"></a>0x02 优势</h3><ul>
<li>右值引用和move语义(move semantics)<ul>
<li>移动语义提高语言内核的基础效率，可以写出更快的代码</li>
</ul>
</li>
<li>哈希表进入标准</li>
<li>编码效率更高效,代码更简洁<ul>
<li>lambda表达式的支持将使代码更简洁</li>
</ul>
</li>
<li>类型自动推导</li>
<li>nullptr, 解决NULL产生的二义性</li>
<li>变长参数模板(variadic template)</li>
</ul>
<h3 id="0x03-auto"><a href="#0x03-auto" class="headerlink" title="0x03 auto"></a>0x03 auto</h3><ul>
<li><p>Example</p>
<p>  // file: auto.cc<br>  // compile: g++ -std=c++11 -o auto auto.cc</p>
<p>  #include <iostream><br>  #include <vector><br>  #include <string><br>  #include <map></map></string></vector></iostream></p>
<p>  void test_map()<br>  {</p>
<pre><code>std::map&lt;std::string, std::string&gt; mymap {{"abc", "123"}, {"apple", "10000"}};

for (auto map_entry : mymap) {
    std::cout &lt;&lt; map_entry.first &lt;&lt; &quot; &lt;&quot; &lt;&lt;
        map_entry.second &lt;&lt; &quot;&gt;&quot; &lt;&lt; std::endl;
}
</code></pre><p>  }<br>  void test_vector()<br>  {</p>
<pre><code>std::vector&lt;int&gt; vec;
vec.push_back(10);
vec.push_back(20);

// read
for (int i : vec) {
    std::cout &lt;&lt; i &lt;&lt; std::endl;
}

// update
for (int&amp; i : vec) {
    i++;
}

// read
for (int i : vec) {
    std::cout &lt;&lt; i &lt;&lt; std::endl;
}
</code></pre><p>  }</p>
<p>  int main(int argc, char* argv[])<br>  {</p>
<pre><code>test_vector();
test_map();

return 0;
</code></pre><p>  }</p>
</li>
</ul>
<h3 id="0x04-move"><a href="#0x04-move" class="headerlink" title="0x04 move"></a>0x04 move</h3><ul>
<li>TODO</li>
</ul>
<h3 id="0x05-lambda"><a href="#0x05-lambda" class="headerlink" title="0x05 lambda"></a>0x05 lambda</h3><p>  <a href="int x, int y"></a> {return x + y;}<br>  <a href="int x, int y"></a> -&gt; int {return x + y;} // 显式指定返回值类型<br>  <a href="int&amp; x"></a> {++x;}   // not return any value (void)<br>  <a href=""></a> {++global_x;}  // access global variable<br>  [] {++global_x;}    // same to previous statement</p>
<p>  []        // 沒有定義任何變量，但必须列出空的方括号。在Lambda表達式中嘗試使用任何外部變量都會導致編譯錯誤。<br>  [x, &amp;y]   // x是按值傳遞，y是按引用傳遞<br>  [&amp;]       // 任何被使用到的外部變量都按引用傳入。<br>  [=]       // 任何被使用到的外部變量都按值傳入。<br>  [&amp;, x]    // x按值傳入。其它變量按引用傳入。<br>  [=, &amp;z]   // z按引用傳入。其它變量按值傳入。</p>
<p>Not lambda:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;algorithm&gt;

bool compare( const int &amp; a, const int &amp; b )
{
    return a &lt; b;
}

using namespace std;

int main ( )
{
    int a[10] = {5,1,2,3,6,9,8,2,3,6};
    sort( a, a+9, compare );
    for ( int i = 0 ; i &lt; 9 ; i ++ )
        cout &lt;&lt; a[i] &lt;&lt; endl;
    return EXIT_SUCCESS;
}
</code></pre><p>Use lambda, not need to defined compare function</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;algorithm&gt;

using namespace std;

int main ( )
{
    int a[10] = {5,1,2,3,6,9,8,2,3,6};
    sort( a, a+9, []( const int &amp; a, const int &amp; b )-&gt;bool{ return a &lt; b; } );
    for ( int i = 0 ; i &lt; 9 ; i ++ )
        cout &lt;&lt; a[i] &lt;&lt; endl;
    return EXIT_SUCCESS;
}
</code></pre><ul>
<li><p>Example 2</p>
<p>  // file: lambda.cc<br>  // compile: g++ -std=c++11 -o lambda lambda.cc</p>
<p>  #include <iostream><br>  #include <vector><br>  #include <algorithm> // for_each<br>  #include <functional> // lambda</functional></algorithm></vector></iostream></p>
<p>  using namespace std;</p>
<p>  void test_lambda()<br>  {</p>
<pre><code>vector&lt;int&gt; iv{5, 4, 3, 2, 1};
int a = 2, b = 1;

for_each(iv.begin(), iv.end(), [b](int &amp;x){cout&lt;&lt;(x + b)&lt;&lt;endl;});

for_each(iv.begin(), iv.end(), [=](int &amp;x){x *= (a + b);});

for_each(iv.begin(), iv.end(), [=](int &amp;x)-&gt;int{return x * (a + b);});
</code></pre><p>  }</p>
<p>  int main(int argc, char* argv[])<br>  {</p>
<pre><code>test_lambda();

return 0;
</code></pre><p>  }</p>
</li>
</ul>
<h3 id="0x06-变长参数模板-variadic-template"><a href="#0x06-变长参数模板-variadic-template" class="headerlink" title="0x06 变长参数模板(variadic template)"></a>0x06 变长参数模板(variadic template)</h3><ul>
<li><p>Example:</p>
<p>  // file: variadic_templates.cc<br>  // compile: g++ -std=c++11 -o variadic_templates variadic_templates.cc<br>  #include <iostream></iostream></p>
<p>  using namespace std;</p>
<p>  inline void EXPECT_EQ(long exp, long value) {</p>
<pre><code>if (exp != value) {
    cout &lt;&lt; &quot;Compare failed, expect:&quot; &lt;&lt; exp &lt;&lt; &quot;, real:&quot; &lt;&lt; value &lt;&lt; endl;
}
</code></pre><p>  }</p>
<p>  template<long n=""><br>  struct print_value_as_warning<br>  {</long></p>
<pre><code>char operator()() {return N + 256;} // always cause overflow
</code></pre><p>  };</p>
<p>  //////////////////////////////////////////////////////////////////////<br>  // Print<br>  template<typename head=""><br>  void Print(Head head) {</typename></p>
<pre><code>cout&lt;&lt; head &lt;&lt;endl;
</code></pre><p>  }</p>
<p>  template<typename head,="" typename...="" tail=""><br>  void Print(Head head, Tail… tail) {</typename></p>
<pre><code>cout&lt;&lt; head &lt;&lt;endl;
Print(tail...);
</code></pre><p>  }</p>
<p>  void test_print()<br>  {</p>
<pre><code>Print(1, -100, 1.5, 1234567890, &quot;C++11&quot;);
</code></pre><p>  }</p>
<p>  //////////////////////////////////////////////////////////////////////<br>  // Add<br>  template <long ...="" args=""> class vsum;</long></p>
<p>  template <long d,="" long="" ...="" args=""><br>  class vsum<d, args...=""> {<br>  public:</d,></long></p>
<pre><code>static const long value = d + vsum&lt;Args...&gt;::value;
</code></pre><p>  };</p>
<p>  template &lt;&gt;<br>  class vsum&lt;&gt; {<br>  public:</p>
<pre><code>static const long value = 0;
</code></pre><p>  };</p>
<p>  void test_sum()<br>  {</p>
<pre><code>long s = vsum&lt;&gt;::value;             EXPECT_EQ(0, s);
s = vsum&lt;5, 5&gt;::value;              EXPECT_EQ(10, s);
s = vsum&lt;5, 2, 3&gt;::value;           EXPECT_EQ(10, s);
s = vsum&lt;3, 3, 1, 3&gt;::value;        EXPECT_EQ(10, s);
s = vsum&lt;2, 2, 2, 2, -1, 3&gt;::value; EXPECT_EQ(10, s);
</code></pre><p>  }</p>
<p>  // prove that sum calculation occurred on compile time<br>  void test_sum_run_on_compile_time()<br>  {</p>
<pre><code>// When do compilation, will got such message：
// In instantiation of ‘char print_size_as_warning&lt;N&gt;::operator()() [with long N = 125]’:
print_value_as_warning&lt;vsum&lt;100,25&gt;::value&gt;()();
</code></pre><p>  }</p>
<p>  //////////////////////////////////////////////////////////////////////<br>  // main<br>  int main(int argc, char* argv[])<br>  {</p>
<pre><code>test_print();
test_sum();
return 0;
</code></pre><p>  }</p>
</li>
<li><p>Reference</p>
<ul>
<li><a href="https://jguegant.github.io/blogs/tech/thread-safe-multi-type-map.html" target="_blank" rel="external">https://jguegant.github.io/blogs/tech/thread-safe-multi-type-map.html</a></li>
<li><a href="https://en.wikipedia.org/wiki/Variadic_template" target="_blank" rel="external">https://en.wikipedia.org/wiki/Variadic_template</a></li>
<li><a href="http://eli.thegreenplace.net/2014/variadic-templates-in-c/" target="_blank" rel="external">http://eli.thegreenplace.net/2014/variadic-templates-in-c/</a></li>
<li><a href="http://elloop.github.io/c++/2015-11-28/never-proficient-cpp-vaargs" target="_blank" rel="external">http://elloop.github.io/c++/2015-11-28/never-proficient-cpp-vaargs</a></li>
</ul>
</li>
</ul>
<h3 id="0x07-区间迭代（range-based-for-loop"><a href="#0x07-区间迭代（range-based-for-loop" class="headerlink" title="0x07 区间迭代（range-based for loop)"></a>0x07 区间迭代（range-based for loop)</h3><ul>
<li><p>Sample:</p>
<p>  vector<int> vec;<br>  vec.push_back(10);<br>  vec.push_back(20);</int></p>
<p>  for (int&amp; i: vec)<br>  {</p>
<pre><code>cout &lt;&lt; i;
</code></pre><p>  }</p>
</li>
<li><p>Sample for map:</p>
<p>  for (auto address_entry: address_book)<br>  {</p>
<pre><code>cout &lt;&lt; address_entry.first &lt;&lt; &quot; &quot; &lt;&lt; address_entry.second &lt;&lt; endl;
</code></pre><p>  }</p>
</li>
<li><p>Others:</p>
<p>  std::map<std::string, std::vector<int="">&gt; map;<br>  std::vector<int> v;<br>  v.push_back(1);<br>  v.push_back(2);<br>  v.push_back(3);<br>  map[“one”] = v;</int></std::string,></p>
<p>  for (const auto&amp; kvp : map)<br>  {</p>
<pre><code>std::cout &lt;&lt; kvp.first &lt;&lt; std::endll;
for (auto v : kvp.second)
{
    std::cout &lt;&lt; v &lt;&lt; std::endl;
}
</code></pre><p>  }</p>
<p>  int arr[] = {1, 2, 3, 4, 5};<br>  for (int&amp; e : arr)<br>  {</p>
<pre><code>e = e*e;
</code></pre><p>  }</p>
</li>
</ul>
<h3 id="0x08-参考"><a href="#0x08-参考" class="headerlink" title="0x08 参考"></a>0x08 参考</h3><ul>
<li><a href="https://github.com/isocpp/CppCoreGuidelines" target="_blank" rel="external">https://github.com/isocpp/CppCoreGuidelines</a></li>
<li><a href="http://mindhacks.cn/2012/08/27/modern-cpp-practices/" target="_blank" rel="external">C++11（及现代C++风格）和快速迭代式开发</a></li>
<li><a href="http://www.cprogramming.com/c++11/c++11-ranged-for-loop.html" target="_blank" rel="external">C++11 range-based for loops</a></li>
<li><a href="https://zh.wikipedia.org/wiki/匿名函数" target="_blank" rel="external">https://zh.wikipedia.org/wiki/匿名函数</a></li>
<li><a href="http://en.cppreference.com/w/cpp/language/lambda" target="_blank" rel="external">http://en.cppreference.com/w/cpp/language/lambda</a></li>
<li><a href="http://en.cppreference.com/w/cpp/utility/move" target="_blank" rel="external">http://en.cppreference.com/w/cpp/utility/move</a></li>
<li><a href="http://blog.jobbole.com/44015/" target="_blank" rel="external">http://blog.jobbole.com/44015/</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/17/cplusplus-11/" data-id="ciqqpe1cx0000nmpvljaf22y8" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-linux-cc-coverage-testing-tool" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/07/linux-cc-coverage-testing-tool/" class="article-date">
  <time datetime="2016-01-06T16:00:00.000Z" itemprop="datePublished">2016-01-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/07/linux-cc-coverage-testing-tool/">Linux c/c++ coverage testing tool</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="gcov-amp-lcov"><a href="#gcov-amp-lcov" class="headerlink" title="gcov &amp; lcov"></a>gcov &amp; lcov</h4><ul>
<li>Reference <a href="http://sdet.org/?p=212" target="_blank" rel="external">http://sdet.org/?p=212</a></li>
<li>step 1: add optional in Makefile, and build with <code>make coverage=yes</code><br>  ifeq ($(coverage), yes)<br>  CXXFLAGS  += -fprofile-arcs -ftest-coverage<br>  LINKERCXX += -fprofile-arcs -ftest-coverage<br>  OPT_FLAGS  = -g3<br>  endif</li>
<li>step 2: run test files</li>
<li>step 3: generate text result by <code>gcov source_file.cc</code>, see result with <code>vim source_file.cc.gcov</code></li>
<li>step 4: generate html result by <code>lcov -c -d ./ -o app.info</code> and <code>genhtml app.info -o cc_result</code></li>
</ul>
<h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h4><ul>
<li><a href="http://sdet.org/?p=212" target="_blank" rel="external">Linux下c/c++项目代码覆盖率的产生方法</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/07/linux-cc-coverage-testing-tool/" data-id="ciqqpe1uu00ebnmpvl7fsl6uk" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/test/">test</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-detect-cc-memory-overflow" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2016/01/03/detect-cc-memory-overflow/" class="article-date">
  <time datetime="2016-01-02T16:00:00.000Z" itemprop="datePublished">2016-01-03</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2016/01/03/detect-cc-memory-overflow/">Detect c/c++ memory overflow</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="Understand-the-process-address-space"><a href="#Understand-the-process-address-space" class="headerlink" title="Understand the process address space"></a>Understand the process address space</h4><ul>
<li>0 to 0x08048000, keep for OS, not used.</li>
<li>0x08048000 to 0x40000000<ul>
<li>read only of code and data</li>
<li>read and write of global variables</li>
<li>heap (malloc and free)</li>
</ul>
</li>
<li>0x40000000<ul>
<li>mmap allocate memory start from here, grow up</li>
</ul>
</li>
<li>0xC0000000<ul>
<li>the stack allocate start from here, grow down</li>
</ul>
</li>
<li>0xC0000000 to 0xFFFFFFFF, use for kernel space</li>
</ul>
<h4 id="Stack-and-heap"><a href="#Stack-and-heap" class="headerlink" title="Stack and heap"></a>Stack and heap</h4><p>For multiple threads program, OS will allocate a stack for every threads.</p>
<ul>
<li>Stack<ul>
<li>ESP register point to the top of stack</li>
<li>EBP register point to the function action record</li>
<li>Parameters be pushed to stack from right to left</li>
<li>Return big data structure</li>
<li>Stack [from high to low]<ul>
<li>Parameter N</li>
<li>Parameter …</li>
<li>Parameter 2</li>
<li>Parameter 1</li>
<li>EIP (Next instruction address)</li>
<li>EBP</li>
<li>local variable 1</li>
<li>local variable 2</li>
<li>local variable …</li>
</ul>
</li>
</ul>
</li>
<li>Heap<ul>
<li>malloc and mmap<ul>
<li><code>malloc</code> for small block memory, address bellow 0x40000000, and extend by brk/sbrk</li>
<li>When big block memory using <code>mmap</code>, address upper 0x40000000.</li>
</ul>
</li>
<li>malloc: put the memory size before the real memory space to user</li>
</ul>
</li>
</ul>
<h4 id="Failures"><a href="#Failures" class="headerlink" title="Failures"></a>Failures</h4><ul>
<li>stack overflow<ul>
<li>failures<ul>
<li>changed global variable</li>
<li>task not work, function not work</li>
<li>some local variable be changed</li>
</ul>
</li>
<li>reason<ul>
<li>thread stack too small</li>
<li>defined too large local variable</li>
<li>function called too deep</li>
</ul>
</li>
</ul>
</li>
<li>global or heap overflow<ul>
<li>failures<ul>
<li>global variable be changed</li>
<li>memory leak</li>
<li>thread-A delete object but thread-B modify object again</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 id="Detect-tools"><a href="#Detect-tools" class="headerlink" title="Detect tools"></a>Detect tools</h4><ul>
<li><code>mcheck</code><ul>
<li>disadvantage: only work on c memory manager, not work for new/delete of c++</li>
</ul>
</li>
<li><code>mprotect</code>, set protection on a region of memory. For more see <code>man mprotect</code></li>
<li><code>electric-fence</code><ul>
<li><a href="http://packages.debian.org/sid/electric-fence" target="_blank" rel="external">http://packages.debian.org/sid/electric-fence</a></li>
<li><a href="http://xinsuiyuer.github.io/blog/2013/10/13/use-electric-fence-to-detect-heap-overruns-and-underruns/" target="_blank" rel="external">http://xinsuiyuer.github.io/blog/2013/10/13/use-electric-fence-to-detect-heap-overruns-and-underruns/</a></li>
<li>disadvantage: like mcheck: only work on c memory manager, not work for<br>new/delete of c++</li>
</ul>
</li>
<li><code>backtrac</code></li>
<li><code>libsigsegv</code></li>
</ul>
<h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference"></a>Reference</h4><ul>
<li><a href="http://m.blog.csdn.net/blog/pecywang/22799705" target="_blank" rel="external">C++编译器越界检查机制</a></li>
<li><a href="http://www.cnblogs.com/djinmusic/archive/2013/02/04/2891753.html" target="_blank" rel="external">定位多线程内存越界问题实践总结</a></li>
<li><a href="http://www.yebangyu.org/blog/2016/02/01/detectmemoryghostinmultithread/" target="_blank" rel="external">多线程内存问题分析之mprotect方法</a></li>
<li><a href="http://blog.codingnow.com/2014/01/out_of_range_bug.html" target="_blank" rel="external">一次内存越界的 bug</a></li>
<li><a href="http://m.blog.csdn.net/blog/ring0lyy/8279286" target="_blank" rel="external">Linux C语言 内存越界问题总结</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2016/01/03/detect-cc-memory-overflow/" data-id="ciqqpe1up00e7nmpvv3npvkuu" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c++</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-memory-program-and-debug" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2015/11/25/memory-program-and-debug/" class="article-date">
  <time datetime="2015-11-24T16:00:00.000Z" itemprop="datePublished">2015-11-25</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/program/">program</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2015/11/25/memory-program-and-debug/">memory program and debug</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="categories-of-memory-error"><a href="#categories-of-memory-error" class="headerlink" title="categories of memory error"></a>categories of memory error</h4><ul>
<li>memory leak</li>
<li>memory overflow</li>
<li>dangling pointers</li>
</ul>
<h4 id="how-to-detect-memory-error"><a href="#how-to-detect-memory-error" class="headerlink" title="how to detect memory error"></a>how to detect memory error</h4><ul>
<li>ps -aux, check VSZ, e.g:<ul>
<li><code>ps -aux |grep -E &#39;VSZ|2892.*firefox&#39; |grep -v grep</code></li>
<li><code>watch -n 5 &#39;ps -aux |grep -E &quot;VSZ|2892.*firefox&quot; |grep -v grep&#39;</code></li>
</ul>
</li>
</ul>
<h4 id="static-program-analysis-tools"><a href="#static-program-analysis-tools" class="headerlink" title="static program analysis tools"></a>static program analysis tools</h4><ul>
<li><a href="http://www.gimpel.com/html/lintinfo.htm" target="_blank" rel="external">pc-lint</a></li>
<li><a href="http://www.splint.org/" target="_blank" rel="external">spint</a>, a tool for statically checking c programs for<br>vulnerabilities and coding mistakes.</li>
</ul>
<h4 id="detect-methods"><a href="#detect-methods" class="headerlink" title="detect methods"></a>detect methods</h4><ul>
<li>mtrace</li>
<li>valgrind</li>
</ul>
<h4 id="reference"><a href="#reference" class="headerlink" title="reference"></a>reference</h4><ul>
<li><a href="https://www.ibm.com/developerworks/cn/aix/library/au-memorytechniques.html" target="_blank" rel="external">内存调试技巧</a></li>
<li><a href="http://www.ibm.com/developerworks/aix/library/au-memorytechniques.html?S_TACT=105AGX52&amp;S_CMP=cn-a-au" target="_blank" rel="external">techniques for memory debugging</a></li>
<li><a href="http://www.cnblogs.com/lanxuezaipiao/p/3604533.html" target="_blank" rel="external">C/C++的内存泄漏检测工具Valgrind memcheck的使用经历</a></li>
<li><a href="https://www.ibm.com/developerworks/cn/linux/l-mleak/" target="_blank" rel="external">如何在linux下检测内存泄漏</a></li>
<li><a href="https://www.ibm.com/developerworks/cn/linux/l-cn-valgrind/" target="_blank" rel="external">应用 Valgrind 发现 Linux 程序的内存问题 </a></li>
<li><a href="http://www.ibm.com/developerworks/cn/linux/l-memory/" target="_blank" rel="external">内存管理内幕</a></li>
<li><a href="http://www.ibm.com/developerworks/cn/linux/l-memory/" target="_blank" rel="external">Inside memory management</a></li>
<li><a href="http://es.gnu.org/~aleksander/valgrind/valgrind-memcheck.pdf" target="_blank" rel="external">Understanding Valgrind memory leak reports</a></li>
<li><a href="https://www.ibm.com/developerworks/cn/linux/l-cn-memleak/" target="_blank" rel="external">在 Linux 平台中调试 C/C++ 内存泄漏方法</a></li>
<li><a href="http://www.cnblogs.com/bangerlee/archive/2011/09/07/2166593.html" target="_blank" rel="external">代码静态分析工具——splint的学习与使用</a></li>
<li><a href="http://www.splint.org/" target="_blank" rel="external">spint</a></li>
<li><a href="http://www.gimpel.com/html/lintinfo.htm" target="_blank" rel="external">pc-lint</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2015/11/25/memory-program-and-debug/" data-id="ciqqpe1um00e3nmpvmyvdt99s" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/valgrind/">valgrind</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-what-i-had-learned-over-the-past-half-year" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2015/11/06/what-i-had-learned-over-the-past-half-year/" class="article-date">
  <time datetime="2015-11-05T16:00:00.000Z" itemprop="datePublished">2015-11-06</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/person/">person</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2015/11/06/what-i-had-learned-over-the-past-half-year/">what I had learned over the past half year</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="Developed-in-cooperation-with-Git"><a href="#Developed-in-cooperation-with-Git" class="headerlink" title="Developed in cooperation with Git"></a>Developed in cooperation with Git</h4><h4 id="Debug-with-GDB"><a href="#Debug-with-GDB" class="headerlink" title="Debug with GDB"></a>Debug with GDB</h4><h4 id="Unit-test-and-ST-with-Google-GTest"><a href="#Unit-test-and-ST-with-Google-GTest" class="headerlink" title="Unit test and ST with Google GTest"></a>Unit test and ST with Google GTest</h4><h4 id="How-to-develop-a-distributed-memory-database"><a href="#How-to-develop-a-distributed-memory-database" class="headerlink" title="How to develop a distributed memory database"></a>How to develop a distributed memory database</h4><h4 id="English-is-very-important"><a href="#English-is-very-important" class="headerlink" title="English is very important"></a>English is very important</h4>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2015/11/06/what-i-had-learned-over-the-past-half-year/" data-id="ciqqpe1uj00e0nmpvgsp8pzzl" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/person/">person</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <a class="extend prev" rel="prev" href="/">&laquo; __('prev')</a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="page-number" href="/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><a class="extend next" rel="next" href="/page/3/">__('next') &raquo;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/english/">english</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/">kernel</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/language/">language</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/math/">math</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/network/">network</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/others/">others</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/person/">person</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/program/">program</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/source/">source</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/storage/">storage</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/tools/">tools</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/FAQ/">FAQ</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/IRC/">IRC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Translation/">Translation</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/api/">api</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/assembly/">assembly</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/awk/">awk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/batch/">batch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/book/">book</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crash/">crash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dot/">dot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/driver/">driver</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/emacs/">emacs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exploit/">exploit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/file-system/">file system</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flowchart/">flowchart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gcc/">gcc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/google/">google</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/graphviz/">graphviz</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hosts/">hosts</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/job/">job</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lisp/">lisp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/makefile/">makefile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/malloc/">malloc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/math/">math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maxima/">maxima</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory/">memory</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netdisk/">netdisk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/others/">others</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandoc/">pandoc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/performance/">performance</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/person/">person</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rsync/">rsync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/skype/">skype</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sms/">sms</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/source/">source</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/">ssh</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stack/">stack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/storage/">storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/study/">study</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svn/">svn</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sync/">sync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time/">time</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tools/">tools</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/valgrind/">valgrind</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vi/">vi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/virtual/">virtual</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wget/">wget</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows/">windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wireshark/">wireshark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/write/">write</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xml/">xml</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/tags/FAQ/" style="font-size: 10px;">FAQ</a> <a href="/tags/IRC/" style="font-size: 10px;">IRC</a> <a href="/tags/Translation/" style="font-size: 13px;">Translation</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/api/" style="font-size: 10px;">api</a> <a href="/tags/assembly/" style="font-size: 10px;">assembly</a> <a href="/tags/awk/" style="font-size: 11px;">awk</a> <a href="/tags/batch/" style="font-size: 14px;">batch</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/book/" style="font-size: 10px;">book</a> <a href="/tags/c/" style="font-size: 16px;">c</a> <a href="/tags/c/" style="font-size: 19px;">c++</a> <a href="/tags/cache/" style="font-size: 10px;">cache</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/database/" style="font-size: 17px;">database</a> <a href="/tags/debug/" style="font-size: 12px;">debug</a> <a href="/tags/dot/" style="font-size: 10px;">dot</a> <a href="/tags/driver/" style="font-size: 10px;">driver</a> <a href="/tags/emacs/" style="font-size: 11px;">emacs</a> <a href="/tags/exploit/" style="font-size: 10px;">exploit</a> <a href="/tags/file-system/" style="font-size: 10px;">file system</a> <a href="/tags/filesystem/" style="font-size: 12px;">filesystem</a> <a href="/tags/flowchart/" style="font-size: 10px;">flowchart</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 12px;">git</a> <a href="/tags/google/" style="font-size: 11px;">google</a> <a href="/tags/graphviz/" style="font-size: 11px;">graphviz</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hosts/" style="font-size: 10px;">hosts</a> <a href="/tags/iscsi/" style="font-size: 14px;">iscsi</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/job/" style="font-size: 10px;">job</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/kernel/" style="font-size: 14px;">kernel</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lisp/" style="font-size: 10px;">lisp</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/makefile/" style="font-size: 10px;">makefile</a> <a href="/tags/malloc/" style="font-size: 10px;">malloc</a> <a href="/tags/math/" style="font-size: 11px;">math</a> <a href="/tags/maxima/" style="font-size: 10px;">maxima</a> <a href="/tags/memory/" style="font-size: 11px;">memory</a> <a href="/tags/memory-overflow/" style="font-size: 10px;">memory overflow</a> <a href="/tags/mtrace/" style="font-size: 10px;">mtrace</a> <a href="/tags/netdisk/" style="font-size: 10px;">netdisk</a> <a href="/tags/network/" style="font-size: 20px;">network</a> <a href="/tags/others/" style="font-size: 18px;">others</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a> <a href="/tags/performance/" style="font-size: 16px;">performance</a> <a href="/tags/person/" style="font-size: 11px;">person</a> <a href="/tags/protobuf/" style="font-size: 11px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/rsync/" style="font-size: 10px;">rsync</a> <a href="/tags/sed/" style="font-size: 11px;">sed</a> <a href="/tags/shell/" style="font-size: 15px;">shell</a> <a href="/tags/skype/" style="font-size: 11px;">skype</a> <a href="/tags/sms/" style="font-size: 10px;">sms</a> <a href="/tags/source/" style="font-size: 11px;">source</a> <a href="/tags/ssh/" style="font-size: 10px;">ssh</a> <a href="/tags/stack/" style="font-size: 10px;">stack</a> <a href="/tags/storage/" style="font-size: 15px;">storage</a> <a href="/tags/study/" style="font-size: 10px;">study</a> <a href="/tags/svn/" style="font-size: 11px;">svn</a> <a href="/tags/sync/" style="font-size: 10px;">sync</a> <a href="/tags/test/" style="font-size: 11px;">test</a> <a href="/tags/time/" style="font-size: 10px;">time</a> <a href="/tags/tools/" style="font-size: 16px;">tools</a> <a href="/tags/valgrind/" style="font-size: 10px;">valgrind</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 14px;">vim</a> <a href="/tags/virtual/" style="font-size: 11px;">virtual</a> <a href="/tags/wget/" style="font-size: 10px;">wget</a> <a href="/tags/windows/" style="font-size: 11px;">windows</a> <a href="/tags/wireshark/" style="font-size: 10px;">wireshark</a> <a href="/tags/write/" style="font-size: 13px;">write</a> <a href="/tags/xml/" style="font-size: 10px;">xml</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">September 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">June 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/02/">February 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">January 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">September 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">August 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">July 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">June 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/04/">April 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/02/">February 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/12/">December 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/09/">September 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
          </li>
        
          <li>
            <a href="/2016/07/17/study-grep-more/">grep工作原理</a>
          </li>
        
          <li>
            <a href="/2016/07/17/2016-04-13-malloc/">malloc</a>
          </li>
        
          <li>
            <a href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
          </li>
        
          <li>
            <a href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Matrix207<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>